// firstPackage/pages/platformCompanyList/platformCompanyList.js

import { getCompanyProxyList } from "../../../service/platform_service"

Page({

  /**
   * 页面的初始数据
   */
  data: {
    houseList: [
      { type: 1 }, { type: 1 }, { type: 1 }, { type: 1 },
    ],
    searchWords: "",

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getCompanyProxyList();
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  //查询平台列表:
  getCompanyProxyList() {
    wx.showLoading();
    getCompanyProxyList(this.data.searchWords, 0, 1000).then(res => {
      wx.hideLoading();
      console.log("JJLog:列表结果是:" + JSON.stringify(res));
      if (res.code == 200) {
        this.setData({
          houseList: res.data || []
        })
      }
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err || "查询失败",
        icon: "none"
      })
      console.error("JJLog:getCompanyProxyList", err);
    })
  },
  searchAction(e) {
    // console.log("JJLog:e是:" + JSON.stringify(e));
    this.setData({
      searchWords: e.detail.searchWord
    })
    this.getCompanyProxyList();
  },

  pushToDetail(e) {
    let companyNumber = e.currentTarget.dataset.item.companyNumber
    let name = e.currentTarget.dataset.item.companyName
    wx.navigateTo({
      url: '/firstPackage/pages/platformCompanyHouse/platformCompanyHouse?companyNumber=' + companyNumber + "&name=" + name,
    })
  },
})